package com.cory.admin.sys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cory.admin.sys.domain.entity.SysRole;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xc
 * @since 2019-02-23
 */
public interface SysRoleMapper extends BaseMapper<SysRole> {

    @Select("select id,tenant_id,user_type,name from sys_role r where r.state = 1 and r.id in (select ur.role_id from sys_user_role ur where ur.user_id = #{userId})")
    List<SysRole> selectListByUserId(Integer userId);


    @Select("select id,tenant_id,user_type,name from sys_role r where r.state = 1 and r.tenant_id =#{tenantId}")
    List<SysRole> selectByTenantId(Integer tenantId);
}


